package com.cqjtu.store.config;

import com.cqjtu.store.interceptors.TokenHandlerInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ProjectName: cqjtu-store
 * @Titile: StoreWebmvcConfig
 * @Author: Lucky
 * @Description: mvc配置类
 */
@SpringBootConfiguration //组合注解
public class StoreWebmvcConfig implements WebMvcConfigurer {

    @Autowired
    private TokenHandlerInterceptor tokenHandlerInterceptor;
    /**
     * 注册拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenHandlerInterceptor)
                .addPathPatterns("/user/**","/api/**") //添加；拦截url
                .excludePathPatterns("/user/login","/user/reg",
                        "/api/category/**",
                        "/api/product/**" //放行商品模块下所有接口
                      ); //放行url
    }
}
